#ifndef DATAMANAGER_H
#define DATAMANAGER_H

#include "communication.h"
#include "cards.h"
#include <QByteArray>
#include "aescrypto.h"


class DataManager
{
public:
    enum GameMode {Single, Network};
    enum RoomMode { Auto, Manual };
    DataManager(const DataManager&) = delete;
    DataManager& operator= (const DataManager&) = delete;

    // 获取单例对象
    static DataManager* getInstance();

    // 设置数据
    void setUserName(QByteArray name);
    void setIp(QByteArray ip);
    void setPort(QByteArray port);
    void setRoomName(QByteArray roomName);
    void setCommunication(Communication* communication);
    void setCards(Cards cs, Cards last3Cards);
    void setGameMode(GameMode mode);
    void setRoomMode(RoomMode mode);

    // 获取数据
    QByteArray getUserName() const;
    QByteArray getIp() const;
    QByteArray getPort() const;
    QByteArray getRoomName() const;
    Cards getCards() const;
    Cards getLast3Cards() const;
    bool isNetworkMode() const;
    bool isManualMode() const;
    Communication* getCommunication() const;

private:
    DataManager() = default;

private:
    static DataManager* m_data;
    QByteArray m_userName;
    QByteArray m_roomName;
    QByteArray m_ip = "192.168.237.128";
    QByteArray m_port = "10000";
    Cards m_cs;     // 用来存储服务端给3个玩家所发送的所有扑克牌
    Cards m_last3Cards;   // 预留给地主的3张底牌
    Communication* m_communication; // 无论在什么位置都能够访问Communication对象，用于与服务器之间进行通信
    GameMode m_mode; // 游戏模式
    RoomMode m_roomMode; // 玩家加入房间的类型
};

#endif // DATAMANAGER_H
